package com.carp.config.interceptorConfig;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getJwtInterceptor())
                .addPathPatterns("/**") //拦截所以请求,同token进行验证
                .excludePathPatterns("/login","/file/**","/index/**");//放行,如果使在同一目标下可以使用如: /login/**,
    }

    //将JwtInterceptor注入spring
    @Bean
    public JwtInterceptor getJwtInterceptor(){
        return  new JwtInterceptor();
    }
}
